home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77653_users.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  16.7 KB  |  525 lines

  1. <%@ Language=VBScript       %>
  2. <%    Option Explicit            %>
  3. <%
  4.     '-------------------------------------------------------------------------
  5.     ' users.asp: users area page - lists all the users,and provides
  6.     '                links for creating new users,editing and deleting users
  7.     '
  8.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  9.     '
  10.     ' Date            Description
  11.     ' 15-Jan-2001    Creation date
  12.     '-------------------------------------------------------------------------
  13. %>
  14.     <!-- #include virtual="/admin/inc_framework.asp" -->
  15.     <!-- #include virtual="/admin/ots_main.asp" -->
  16. <%
  17.     '-------------------------------------------------------------------------
  18.     ' Global Constants
  19.     '-------------------------------------------------------------------------
  20.     Const NAME_COLUMN = 0
  21.     Const FULLNAME_COLUMN = 1
  22.     Const USERS_PER_PAGE = 100
  23.     CONST CONST_UF_ACCOUNTDISABLE    = &H0002
  24.  
  25.     '
  26.     ' Name of this source file
  27.     Const SOURCE_FILE = "Users.asp"
  28.     '
  29.     ' Flag to toggle optional tracing output
  30.     Const ENABLE_TRACING = TRUE
  31.     
  32.     '-------------------------------------------------------------------------
  33.     ' Global Variables
  34.     '-------------------------------------------------------------------------
  35.     Dim g_bSearchChanged
  36.     Dim g_iSearchCol
  37.     Dim g_sSearchColValue
  38.  
  39.     Dim g_bPagingInitialized
  40.     Dim g_bPageChangeRequested
  41.     Dim g_sPageAction
  42.     Dim g_iPageMin
  43.     Dim g_iPageMax
  44.     Dim g_iPageCurrent
  45.  
  46.     Dim g_bSortRequested
  47.     Dim g_iSortCol
  48.     Dim g_sSortSequence
  49.     Dim G_strReturnURL            'return url to servefailure page
  50.     
  51.     G_strReturnURL="../tasks.asp?Tab1=TabUsersAndGroups"
  52.     '-------------------------------------------------------------------------
  53.     ' Local Variables
  54.     '-------------------------------------------------------------------------
  55.     
  56.     
  57.     Dim page
  58.     Dim L_APPLIANCE_USERS
  59.     Dim L_DESCRIPTION_HEADING
  60.     Dim L_COLUMN_NAME
  61.     Dim L_COLUMN_FULLNAME
  62.     Dim L_TASKS_TEXT
  63.     Dim L_SERVEAREABUTTON_NEW
  64.     Dim L_NEW_ROLLOVERTEXT
  65.     Dim L_SERVEAREABUTTON_DELETE
  66.     Dim L_SERVEAREABUTTON_SETPASSWORD
  67.     Dim L_SERVEAREABUTTON_PROPERTIES
  68.     Dim L_DELETE_ROLLOVERTEXT
  69.     Dim L_PASSWORD_ROLLOVERTEXT
  70.     Dim L_PROPERTIES_ROLLOVERTEXT
  71.     Dim L_USERDISABLED_INFORMATION
  72.     Dim L_YES_TEXT
  73.     Dim L_NO_TEXT
  74.     
  75.     'error messages
  76.     Dim L_FAILEDTOGETUSERS_ERRORMESSAGE
  77.     
  78.     L_APPLIANCE_USERS                =GetLocString("usermsg.dll","&H40300001", "")
  79.     L_DESCRIPTION_HEADING            =GetLocString("usermsg.dll","&H40300002", "")
  80.     L_COLUMN_NAME                    =GetLocString("usermsg.dll","&H40300003", "")
  81.     L_COLUMN_FULLNAME                =GetLocString("usermsg.dll","&H40300004", "")
  82.     L_TASKS_TEXT                    =GetLocString("usermsg.dll","&H40300005", "")
  83.     L_SERVEAREABUTTON_NEW            =GetLocString("usermsg.dll","&H40300006", "")
  84.     L_NEW_ROLLOVERTEXT                =GetLocString("usermsg.dll","&H40300007", "")
  85.     L_SERVEAREABUTTON_DELETE        =GetLocString("usermsg.dll","&H40300008", "")
  86.     L_SERVEAREABUTTON_SETPASSWORD    =GetLocString("usermsg.dll","&H40300009", "")
  87.     L_SERVEAREABUTTON_PROPERTIES    =GetLocString("usermsg.dll","&H4030000A", "")
  88.     L_DELETE_ROLLOVERTEXT            =GetLocString("usermsg.dll","&H4030000B", "")
  89.     L_PASSWORD_ROLLOVERTEXT         =GetLocString("usermsg.dll","&H4030000C", "")
  90.     L_PROPERTIES_ROLLOVERTEXT        =GetLocString("usermsg.dll","&H4030000D", "")
  91.     L_USERDISABLED_INFORMATION      =GetLocString("usermsg.dll","&H40300058", "")
  92.     L_YES_TEXT                         =GetLocString("usermsg.dll","403003E8", "") 
  93.     L_NO_TEXT                         =GetLocString("usermsg.dll","403003E9", "")
  94.     
  95.     'error messages
  96.     L_FAILEDTOGETUSERS_ERRORMESSAGE     =GetLocString("usermsg.dll","&HC0300012", "")
  97.     
  98.     '
  99.     ' Create Page
  100.     Call SA_CreatePage( L_APPLIANCE_USERS, "", PT_AREA, page )
  101.  
  102.     '
  103.     ' Show page
  104.     Call SA_ShowPage( page )
  105.  
  106.     '---------------------------------------------------------------------
  107.     ' Function name:    OnInitPage
  108.     ' Description:        Called to signal first time processing for this page. 
  109.     ' Input Variables:    PageIn and EventArg
  110.     ' Output Variables:    None
  111.     ' Return Values:    TRUE to indicate initialization was successful. FALSE to indicate
  112.     '                    errors. Returning FALSE will cause the page to be abandoned.
  113.     ' Global Variables: None
  114.     ' Called to signal first time processing for this page. Use this method
  115.     ' to do first time initialization tasks. 
  116.     '---------------------------------------------------------------------
  117.     Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  118.         OnInitPage = TRUE
  119.         
  120.         If ( ENABLE_TRACING ) Then 
  121.             Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  122.         End If
  123.             
  124.         g_bPagingInitialized = FALSE
  125.         g_iPageCurrent = 1
  126.  
  127.         g_iSortCol = 0
  128.         g_sSortSequence = "A"
  129.         
  130.     End Function
  131.  
  132.     '---------------------------------------------------------------------
  133.     ' Function name:    OnServeAreaPage
  134.     ' Description:        Called when the page needs to be served. 
  135.     ' Input Variables:    PageIn, EventArg
  136.     ' Output Variables:    None
  137.     ' Return Values:    TRUE to indicate no problems occured. FALSE to indicate errors.
  138.     '                    Returning FALSE will cause the page to be abandoned.
  139.     ' Global Variables: In:g_bPageChangeRequested,g_sPageAction,
  140.     '                    g_bSearchRequested,g_iSearchCol,g_sSearchColValue
  141.     '                    In:L_(*)-Localization Strings
  142.     ' Called when the page needs to be served. Use this method to serve content.
  143.     '---------------------------------------------------------------------
  144.     Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  145.         If ( ENABLE_TRACING ) Then 
  146.             Call SA_TraceOut(SOURCE_FILE, "OnServeAreaPage")
  147.         End If
  148.         
  149.         Dim tableUser
  150.         Dim colFlags
  151.         Dim iUserCount
  152.         Dim nReturnValue
  153.         Dim strFlag
  154.         Dim strUserDisabled
  155.         Dim    strUrlBase
  156.         
  157.         strFlag="noval"
  158.         
  159.         ' Create the table
  160.         '
  161.         tableUser = OTS_CreateTable("", L_DESCRIPTION_HEADING)
  162.  
  163.  
  164.         '
  165.         ' If the search criteria changed then we need to recompute the paging range
  166.         If ( TRUE = g_bSearchChanged ) Then
  167.             '
  168.             ' Need to recalculate the paging range
  169.             g_bPagingInitialized = FALSE
  170.             '
  171.             ' Restarting on page #1
  172.             g_iPageCurrent = 1
  173.         End If
  174.  
  175.  
  176.         '
  177.         ' Name column is searchable and is contains key to row
  178.         colFlags = (OTS_COL_SORT OR OTS_COL_SEARCH OR OTS_COL_KEY)
  179.         nReturnValue= OTS_AddTableColumn(tableUser, OTS_CreateColumnEx( L_COLUMN_NAME, "left", colFlags, 15 ))
  180.         If nReturnValue <> gc_ERR_SUCCESS Then
  181.                 SA_ServeFailurePage L_OTS_ADDCOLOUMNFAIL_ERRORMESSAGE
  182.                 OnServeAreaPage = false
  183.                 Exit Function
  184.         End IF
  185.  
  186.         '
  187.         ' Fullname is searchable
  188.         colFlags = OTS_COL_SORT OR OTS_COL_SEARCH
  189.         '
  190.         ' Create the column and add it to the table
  191.         nReturnValue=OTS_AddTableColumn(tableUser, OTS_CreateColumnEx( L_COLUMN_FULLNAME, "left", colFlags, 50))
  192.         If nReturnValue <> gc_ERR_SUCCESS Then
  193.                 SA_ServeFailurePage L_OTS_ADDCOLOUMNFAIL_ERRORMESSAGE
  194.                 OnServeAreaPage = false
  195.                 Exit Function
  196.         End IF
  197.         
  198.         colFlags = 0
  199.         nReturnValue=OTS_AddTableColumn(tableUser, OTS_CreateColumnEx( L_USERDISABLED_INFORMATION, "left", colFlags, 15))
  200.         If nReturnValue <> gc_ERR_SUCCESS Then
  201.                 SA_ServeFailurePage L_OTS_ADDCOLOUMNFAIL_ERRORMESSAGE
  202.                 OnServeAreaPage = false
  203.                 Exit Function
  204.         End IF
  205.         
  206.  
  207.         '
  208.         ' Fetch the list of users and add them to the table
  209.         '
  210.         Dim objContainer
  211.         Dim objUser
  212.         Dim strIUserName
  213.         Dim strIWAMName
  214.         Dim strComputerName
  215.         
  216.         strComputerName = GetComputerName()
  217.         strIUserName = "IUSR_" + strComputerName
  218.         strIWAMName  = "IWAM_" + strComputerName
  219.  
  220.         '
  221.         ' ADSI call to get the local computer object
  222.         Set objContainer = GetObject("WinNT://" + strComputerName )
  223.         
  224.         '
  225.         ' ADSI call to get the collection of local users
  226.         objContainer.Filter = Array("User")
  227.  
  228.         iUserCount = 0
  229.         For Each objUser in objContainer
  230.             
  231.             If objUser.UserFlags And CONST_UF_ACCOUNTDISABLE Then
  232.                 strUserDisabled = L_YES_TEXT
  233.             Else
  234.                 strUserDisabled = L_NO_TEXT
  235.             End If
  236.             
  237.             If ( ( StrComp( objUser.Name, strIUserName,1 ) <> 0 ) AND _
  238.                  ( StrComp( objUser.Name, strIWAMName,1 ) <> 0 ) ) Then
  239.             
  240.                 If ( Len( g_sSearchColValue ) <= 0 ) Then
  241.                     '
  242.                     ' Search criteria blank, select all rows
  243.                     '
  244.                     iUserCount = iUserCount + 1
  245.     
  246.                     '
  247.                     ' Verify that the current user part of the current page
  248.                     If ( IsItemOnPage( iUserCount, g_iPageCurrent, USERS_PER_PAGE) ) Then
  249.                         Call OTS_AddTableRow( tableUser, Array(objUser.Name, objUser.FullName,strUserDisabled))
  250.                         strFlag="yesval"
  251.                     End If
  252.                     
  253.                 Else
  254.                     '
  255.                     ' Check the Search criteria
  256.                     '
  257.                     Select Case (g_iSearchCol)
  258.                         
  259.                         Case NAME_COLUMN
  260.                             If ( InStr(1, objUser.Name, g_sSearchColValue, 1) ) Then
  261.                                 iUserCount = iUserCount + 1
  262.                                 '
  263.                                 ' Verify that the current user part of the current page
  264.                                 If ( IsItemOnPage( iUserCount, g_iPageCurrent, USERS_PER_PAGE) ) Then
  265.                                     Call OTS_AddTableRow( tableUser, Array(objUser.Name, objUser.FullName,strUserDisabled))
  266.                                     strFlag="yesval"
  267.                                 End If
  268.                             End If
  269.                                 
  270.                         Case FULLNAME_COLUMN
  271.                             If ( InStr(1, objUser.FullName, g_sSearchColValue, 1) ) Then
  272.                                 iUserCount = iUserCount + 1
  273.                                 '
  274.                                 ' Verify that the current user part of the current page
  275.                                 If ( IsItemOnPage( iUserCount, g_iPageCurrent, USERS_PER_PAGE) ) Then
  276.                                     Call OTS_AddTableRow( tableUser, Array(objUser.Name, objUser.FullName,strUserDisabled))
  277.                                     strFlag="yesval"
  278.                                 End If
  279.                             End If
  280.                                 
  281.                         Case Else
  282.                             Call SA_TraceOut(SOURCE_FILE, "Unrecognized search column: " + CStr(g_iSearchCol))
  283.                             iUserCount = iUserCount + 1
  284.                             '
  285.                             ' Verify that the current user part of the current page
  286.                             If ( IsItemOnPage( iUserCount, g_iPageCurrent, USERS_PER_PAGE) ) Then
  287.                                 Call OTS_AddTableRow( tableUser, Array(objUser.Name, objUser.FullName,strUserDisabled))
  288.                                 strFlag="yesval"
  289.                             End If
  290.                     End Select
  291.                 End If
  292.             End If            
  293.         Next
  294.         
  295.         ' Set Tasks section title
  296.         Call OTS_SetTableTasksTitle(tableUser, L_TASKS_TEXT)
  297.  
  298.         '
  299.         ' Add the tasks associated with User objects
  300.         strUrlBase = "users/user_new.asp"
  301.         call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  302.         call SA_MungeURL(strUrlBase,"Tab2",GetTab2())    
  303.         
  304.         Call OTS_AddTableTask( tableUser, OTS_CreateTaskEx(L_SERVEAREABUTTON_NEW, _
  305.                                         L_NEW_ROLLOVERTEXT, _
  306.                                         strUrlBase,_
  307.                                         OTS_PT_TABBED_PROPERTY, "OTS_TaskAlways") )
  308.                                         
  309.         strUrlBase = "users/user_delete.asp"
  310.         call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  311.         call SA_MungeURL(strUrlBase,"Tab2",GetTab2())    
  312.         Call OTS_AddTableTask( tableUser, OTS_CreateTaskEx(L_SERVEAREABUTTON_DELETE, _
  313.                                             L_DELETE_ROLLOVERTEXT, _
  314.                                             strUrlBase ,_
  315.                                             OTS_PT_PROPERTY, "OTS_TaskAny") )
  316.  
  317.         strUrlBase = "users/user_setpassword.asp"
  318.         call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  319.         call SA_MungeURL(strUrlBase,"Tab2",GetTab2())    
  320.         Call OTS_AddTableTask( tableUser, OTS_CreateTaskEx(L_SERVEAREABUTTON_SETPASSWORD, _
  321.                                             L_PASSWORD_ROLLOVERTEXT, _
  322.                                             strUrlBase ,_
  323.                                             OTS_PT_TABBED_PROPERTY, "OTS_TaskOne") )
  324.                                 
  325.         strUrlBase = "users/user_prop.asp"
  326.         call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  327.         call SA_MungeURL(strUrlBase,"Tab2",GetTab2())    
  328.         Call OTS_AddTableTask( tableUser, OTS_CreateTaskEx(L_SERVEAREABUTTON_PROPERTIES, _
  329.                                             L_PROPERTIES_ROLLOVERTEXT, _
  330.                                             strUrlBase ,_
  331.                                             OTS_PT_TABBED_PROPERTY, "OTS_TaskAny") )
  332.                                                                                     
  333.         
  334.         Set objContainer = Nothing
  335.  
  336.         
  337.         '
  338.         ' Enable paging feature
  339.         '
  340.         Call OTS_EnablePaging(tableUser, TRUE)
  341.         
  342.         '
  343.         ' If paging range needs to be initialised then
  344.         ' we need to figure out how many pages we are going to display
  345.         If ( FALSE = g_bPagingInitialized ) Then
  346.             g_iPageMin = 1
  347.             
  348.             g_iPageMax = Int(iUserCount / USERS_PER_PAGE )
  349.             If ( (iUserCount MOD USERS_PER_PAGE) > 0 ) Then
  350.                 g_iPageMax = g_iPageMax + 1
  351.             End If
  352.             
  353.             g_iPageCurrent = 1
  354.             Call OTS_SetPagingRange(tableUser, g_iPageMin, g_iPageMax, g_iPageCurrent)
  355.         End If
  356.  
  357.                                 
  358.         '
  359.         ' Sort the table
  360.         '
  361.         Call OTS_SortTable(tableUser, g_iSortCol, g_sSortSequence, SA_RESERVED)
  362.         
  363.         '
  364.         ' Set MultiSelection enabled
  365.         '
  366.         Call OTS_SetTableMultiSelection(tableUser,TRUE)
  367.         
  368.         
  369.         '
  370.         ' Send table to the response stream
  371.         '
  372.         Call OTS_ServeTable(tableUser)
  373.  
  374.         '
  375.         ' All done...
  376.         OnServeAreaPage = TRUE
  377.     End Function
  378.  
  379.  
  380.  
  381.     '---------------------------------------------------------------------
  382.     ' Function name:    OnSearchNotify()
  383.     ' Description:        Search notification event handler. When one or more columns are
  384.     '                    marked with the OTS_COL_SEARCH flag, the Web Framework fires
  385.     '                    this event
  386.     ' Input Variables:    PageIn,EventArg,sItem,sValue
  387.     ' Output Variables:    PageIn,EventArg,sItem,sValue
  388.     ' Returns:    Always returns TRUE
  389.     '---------------------------------------------------------------------
  390.     Public Function OnSearchNotify(ByRef PageIn, _
  391.                                         ByRef EventArg, _
  392.                                         ByRef sItem, _
  393.                                         ByRef sValue )
  394.             OnSearchNotify = TRUE
  395.  
  396.             '
  397.             ' User pressed the search GO button
  398.             '
  399.             If SA_IsChangeEvent(EventArg) Then
  400.                 If ( ENABLE_TRACING ) Then 
  401.                     Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Change Event Fired")
  402.                 End If
  403.                 g_bSearchChanged = TRUE
  404.                 g_iSearchCol = Int(sItem)
  405.                 g_sSearchColValue = CStr(sValue)
  406.             '
  407.             ' User clicked a column sort, OR clicked either the page next or page prev button
  408.             ElseIf SA_IsPostBackEvent(EventArg) Then
  409.                 If ( ENABLE_TRACING ) Then 
  410.                     Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Postback Event Fired")
  411.                 End If
  412.                 g_bSearchChanged = FALSE
  413.                 g_iSearchCol = Int(sItem)
  414.                 g_sSearchColValue = CStr(sValue)
  415.             '
  416.             ' Unknown event source
  417.             Else
  418.                 If ( ENABLE_TRACING ) Then 
  419.                     Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  420.                 End If
  421.             End IF
  422.             
  423.             
  424.     End Function
  425.  
  426.     '---------------------------------------------------------------------
  427.     ' Function:            OnPagingNotify()
  428.     ' Function name:    OnPagingNotify()
  429.     ' Description:        Paging notification event handler.                
  430.     ' Input Variables:    PageIn,EventArg,sPageAction,iPageMin,iPageMax,iPageCurrent
  431.     ' Output Variables:    PageIn,EventArg
  432.     ' Return Values:    Always returns TRUE
  433.     ' Global Variables: G_*
  434.     '---------------------------------------------------------------------
  435.     Public Function OnPagingNotify(ByRef PageIn, _
  436.                                         ByRef EventArg, _
  437.                                         ByVal sPageAction, _
  438.                                         ByVal iPageMin, _
  439.                                         ByVal iPageMax, _
  440.                                         ByVal iPageCurrent )
  441.             OnPagingNotify = TRUE
  442.             
  443.             g_bPagingInitialized = TRUE
  444.             
  445.             '
  446.             ' User pressed either page next or page previous
  447.             '
  448.             If SA_IsChangeEvent(EventArg) Then
  449.                 If ( ENABLE_TRACING ) Then 
  450.                     Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Change Event Fired")
  451.                 End If
  452.                 g_bPageChangeRequested = TRUE
  453.                 g_sPageAction = CStr(sPageAction)
  454.                 g_iPageMin = iPageMin
  455.                 g_iPageMax = iPageMax
  456.                 g_iPageCurrent = iPageCurrent
  457.             '
  458.             ' User clicked a column sort OR the search GO button
  459.             ElseIf SA_IsPostBackEvent(EventArg) Then
  460.                 If ( ENABLE_TRACING ) Then 
  461.                     Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Postback Event Fired")
  462.                 End If
  463.                 g_bPageChangeRequested = FALSE
  464.                 g_sPageAction = CStr(sPageAction)
  465.                 g_iPageMin = iPageMin
  466.                 g_iPageMax = iPageMax
  467.                 g_iPageCurrent = iPageCurrent
  468.             '
  469.             ' Unknown event source
  470.             Else
  471.                 If ( ENABLE_TRACING ) Then 
  472.                     Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnPagingNotify()")
  473.                 End If
  474.             End IF
  475.             
  476.     End Function
  477.  
  478.  
  479.     '---------------------------------------------------------------------
  480.     ' Function:            OnSortNotify()
  481.     ' Function name:    GetServices
  482.     ' Description:        Sorting notification event handler.
  483.     ' Input Variables:    PageIn,EventArg,sortCol,sortSeq
  484.     ' Output Variables:    PageIn,EventArg
  485.     ' Return Values:    Always returns TRUE
  486.     ' Global Variables: G_*
  487.     '---------------------------------------------------------------------
  488.     Public Function OnSortNotify(ByRef PageIn, _
  489.                                         ByRef EventArg, _
  490.                                         ByVal sortCol, _
  491.                                         ByVal sortSeq )
  492.         OnSortNotify = TRUE
  493.             
  494.         g_iSortCol = sortCol
  495.         g_sSortSequence = sortSeq
  496.         g_bSortRequested = TRUE
  497.             
  498.     End Function
  499.     '---------------------------------------------------------------------
  500.     ' Function:            IsItemOnPage()
  501.     ' Description:        Verify that the current user part of the current page.
  502.     ' Input Variables:    iCurrentItem
  503.     ' Output Variables:    None
  504.     ' Return Values:    TRUE or FALSE
  505.     ' Global Variables: None
  506.     '---------------------------------------------------------------------
  507.  
  508.     Private Function IsItemOnPage(ByVal iCurrentItem, iCurrentPage, iItemsPerPage)
  509.         Dim iLowerLimit
  510.         Dim iUpperLimit
  511.  
  512.         iLowerLimit = ((iCurrentPage - 1) * iItemsPerPage )
  513.         iUpperLimit = iLowerLimit + iItemsPerPage + 1
  514.         
  515.         If ( iCurrentItem > iLowerLimit AND iCurrentItem < iUpperLimit ) Then
  516.             IsItemOnPage = TRUE
  517.         Else
  518.             IsItemOnPage = FALSE
  519.         End If
  520.         
  521.     End Function
  522.     %>
  523.  
  524.      
  525.